package com.zz.lambda;

public class Test {
    public static void main(String args[]) {
        //匿名内部类
//       Animal animal = new Animal() {
//           @Override
//           public void run() {
//               System.out.println("跑的很快");
//           }
//       };
//        animal.run()

        //不是所有匿名内部类都能用lambda简化，只能简化函数式接口匿名内部类
        //错误示范
//        Animal animal = () -> {
//            System.out.println("跑的很快");
//        };
//        animal.run();

        //正确示范，函数式指的是接口中只有一个方法
        Swimming s = () -> {
            System.out.println("游泳有益健康");
        };
        s.swimming();

        //省略参数类型
        People p = (name, time) -> {
            System.out.println(name + "需要工作" + time);
        };
        p.work("Doctor", 12);

        People p1 = (name, time)->  System.out.println(name + "需要工作" + time);
        p1.work("老师", 9);

        Fly fly = speed -> System.out.println(speed + "不同");
        fly.speed(34.4);
    }
}

interface Fly{
    void speed(double speed);
}
interface People{
    void work(String name, int time);
}

interface Swimming{
    void swimming();
}

abstract class Animal{
    public abstract void run();
}
